import 'dart:io';

import 'package:device_info/device_info.dart';

class DeviceUtil {
//系统标记类
  static bool isDebug = !bool.fromEnvironment("dart.vm.product");
  static bool isAndroid = Platform.isAndroid;
  static bool isIos = Platform.isIOS;

  IosDeviceInfo iosDeviceInfo;
  AndroidDeviceInfo androidDeviceInfo;

  static DeviceUtil _deviceManger = DeviceUtil._internal();
  factory DeviceUtil() {
    return _deviceManger;
  }
  DeviceUtil._internal();

  Future initPlatInfo() async {
    DeviceInfoPlugin deviceInfo = new DeviceInfoPlugin();
    if (Platform.isIOS) {
      iosDeviceInfo = await deviceInfo.iosInfo;
    } else if (Platform.isAndroid) {
      androidDeviceInfo = await deviceInfo.androidInfo;
    }
  }

  String getSystemVersion() {
    if (isAndroid) {
      if (null != androidDeviceInfo) {
        return androidDeviceInfo.version.release;
      } else {
        return "9.0";
      }
    } else {
      if (iosDeviceInfo != null) {
        return iosDeviceInfo.systemVersion;
      } else {
        return "10.0";
      }
    }
  }
}
